package telsoft.app.form;

import java.util.*;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import telsoft.admin.util.*;
import telsoft.swing.*;
import telsoft.util.*;
import telsoft.comm.protocol.DataTransmit;

public class FormArea extends JXFrame implements ControlButtonListener
{
    private DefaultMutableTreeNode ndResultSearch;
    private DefaultMutableTreeNode ndRootAreaTree;
    private JXText txtAreaCode,txtParentCode,txtName,txtFullName;
    private JXCombo cboCenter,cboStatus;
    private VectorTable tblAreaList;
    public PanelControlButton pnlControlButton;
    ////////////////////////////////////////////////////////
    public FormArea() throws Exception
    {
	jbInit();
    }

    ////////////////////////////////////////////////////////
    public void jbInit() throws Exception
    {
	buildForm();
	txtAreaCode = (JXText)formData.getField("Area_code");//lay gia tri cac truong trong form
	txtParentCode = (JXText)formData.getField("Parent_code");
	txtName = ((JXText)formData.getField("Name"));
	txtFullName = ((JXText)formData.getField("Fullname"));
	cboCenter = ((JXCombo)formData.getControl("Center"));
	cboStatus = ((JXCombo)formData.getControl("Status"));
	tblAreaList = ((VectorTable)formData.getControl("tblListDetail"));
	pnlControlButton = ((PanelControlButton)formData.getLayout("ControlButton"));
	pnlControlButton.setNormalState();
	onChangeAction(ACTION_NONE,ACTION_NONE);
	((DnDTree)formData.getControl("TreeArea")).setToggleClickCount(0);
	((DnDTree)formData.getControl("TreeArea")).setEditable(false);
	((DnDTree)formData.getControl("TreeArea")).setShowsRootHandles(true);
	((DnDTree)formData.getControl("TreeArea")).setAllowCopy(false);
	TreeCellRenderer renderer = new DefaultTreeCellRenderer()
	{
	    public Dimension getPreferredSize()
	    {
		return new Dimension(super.getPreferredSize().width,19);
	    }

//	    public Component getTreeCellRendererComponent(JTree tree,Object value,
//		boolean sel,
//		boolean expanded,
//		boolean leaf,int row,
//		boolean hasFocus)
//	    {
//		super.getTreeCellRendererComponent(tree,value,sel,expanded,leaf,row,hasFocus);
//		DefaultMutableTreeNode nd = (DefaultMutableTreeNode)value;
//		Icon icon = ImageModule.iconGroupAllow;
//		if(nd.getUserObject() instanceof Vector)
//		{
//		    if(nd.getChildCount() > 0)
//		    {
//			icon = ImageModule.iconGroupAllow;
//		    }
//		    else
//		    {
//			icon = ImageModule.iconMemberAllow;
//		    }
//		    setIcon(icon);
//		    setDisabledIcon(icon);
//		}
//		else
//		{
//		    setIcon(icon);
//		    setDisabledIcon(icon);
//		}
//		return this;
//	    }
	};
	((DnDTree)formData.getControl("TreeArea")).setCellRenderer(renderer);
	////////////////////////////////////////////////////////
	Thread thr = new Thread()
	{
	    public void run()
	    {
		search();
	    }
	};
	thr.start();
	////////////////////////////////////////////////////////
	((DnDTree)formData.getControl("TreeArea")).getSelectionModel().addTreeSelectionListener(new TreeSelectionListener()
	{
	    public void valueChanged(TreeSelectionEvent e)//thay dổi hieu luc button khi click nut
	    {
		TreePath path = ((DnDTree)formData.getControl("TreeArea")).getSelectionPath();
		if(path != null)
		{
		    ((DnDTree)formData.getControl("TreeArea")).scrollPathToVisible(path);
		    DefaultMutableTreeNode ndSeletionNode = (DefaultMutableTreeNode)path.getLastPathComponent();
		    if(ndSeletionNode.isRoot())
		    {
			pnlControlButton.btnAddCopy.setEnabled(false);
			pnlControlButton.btnModify.setEnabled(false);
			pnlControlButton.btnRemove.setEnabled(false);
		    }
		    else
		    {
			pnlControlButton.btnAddCopy.setEnabled(true);
			pnlControlButton.btnModify.setEnabled(true);
			pnlControlButton.btnRemove.setEnabled(true);

		    }
		}
		fillTableArea();
		fillDetailValue();
	    }
	});
	////////////////////////////////////////////////////////
	((DnDTree)formData.getControl("TreeArea")).addMouseListener(new MouseAdapter()
	{
	    public void mousePressed(MouseEvent e)
	    {
		if(e.getClickCount() > 1)
		{
		    TreePath path = ((DnDTree)formData.getControl("TreeArea")).getSelectionPath();
		    if(path != null)
		    {
			DefaultMutableTreeNode ndSeletionNode = (DefaultMutableTreeNode)path.getLastPathComponent();
			if(ndSeletionNode != ((DnDTree)formData.getControl("TreeArea")).getRoot())
			{
			    pnlControlButton.btnModify.doClick();
			}
		    }
		}
	    }
	});
    }

    ////////////////////////////////////////////////////////
    public DnDTree createTreeArea()
    {
	return new DnDTree()
	{
	    ////////////////////////////////////////////////////////////////
	    public String convertValueToText(Object value,boolean selected,boolean expanded,
					     boolean leaf,int row,boolean hasFocus)
	    {
		if(value instanceof DefaultMutableTreeNode)
		{
		    Object objUserObject = ((DefaultMutableTreeNode)value).getUserObject();
		    if(objUserObject instanceof Vector)
		    {
			Vector vt = (Vector)objUserObject;
			return vt.elementAt(0) + " - " + vt.elementAt(3).toString();
		    }
		}
		return super.convertValueToText(value,selected,expanded,leaf,row,hasFocus);
	    }

	    ////////////////////////////////////////////////////////
	    public boolean isDropAllowed(TreePath[] paths)
	    {
		if(pathDestination != null)
		{
		    expandPath(pathDestination);
		}
		return true;
	    }
	};
    }

    ////////////////////////////////////////////////////////
    public boolean add()
    {
	try
	{
	    DataTransmit request = new DataTransmit();
	    request.setString("AreaCode",txtAreaCode.getText().trim());
	    request.setString("ParentCode",txtParentCode.getText().trim());
	    request.setString("Name",txtName.getText().trim());
	    request.setString("FullName",txtFullName.getText().trim());
	    request.setString("Center",StringUtil.nvl(cboCenter.getSelectedValue(),""));
	    request.setString("Status",StringUtil.nvl(cboStatus.getSelectedValue(),""));
	    DataTransmit response = AppClient.sendRequest("telsoft.app.bean.AreaBean","insert",request);
	    //Update UI
	    Vector vtRowData = new Vector();
	    vtRowData.addElement(txtAreaCode.getText().trim());
	    vtRowData.addElement(txtParentCode.getText().trim());
	    vtRowData.addElement(txtName.getText().trim());
	    vtRowData.addElement(txtFullName.getText().trim());
	    vtRowData.addElement(StringUtil.nvl(cboCenter.getSelectedValue(),""));
	    vtRowData.addElement(StringUtil.nvl(cboStatus.getSelectedValue(),""));
	    vtRowData.addElement(response.getString("mstrPrimaryKey"));
	    tblAreaList.addRow(vtRowData);
	    if(tblAreaList.getRowCount() > 0)
	    {
		int iSelected = tblAreaList.getRowCount() - 1;
		tblAreaList.changeSelectedRow(iSelected);
	    }

	    DefaultMutableTreeNode nd = null;
	    String strParentCode = txtParentCode.getText().trim();
	    ndRootAreaTree = ((DnDTree)formData.getControl("TreeArea")).getRoot();
	    if(!strParentCode.equals(""))
	    {
		searchNode(strParentCode,ndRootAreaTree);
		if(ndResultSearch.getChildCount() == 0)
		{
		    ndResultSearch.setAllowsChildren(true);
		}
		nd = createTreeNode(vtRowData);
		((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).insertNodeInto(nd,ndResultSearch,ndResultSearch.getChildCount());
	    }
	    else
	    {
		nd = createTreeNode(vtRowData);
		((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).insertNodeInto(nd,ndRootAreaTree,ndRootAreaTree.getChildCount());
	    }
	    ((DnDTree)formData.getControl("TreeArea")).setSelectionPath(new TreePath(((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).getPathToRoot(nd)));
	}
	catch(Exception e)
	{
	    e.printStackTrace();
	    MessageBox.showMessageDialog(this,e,Global.APP_NAME,MessageBox.ERROR_MESSAGE);
	    txtAreaCode.requestFocus();
	    return false;
	}
	return true;
    }

    ////////////////////////////////////////////////////////
    public boolean modify()
    {
	try
	{
	    String strAreaId = "";
	    String strOldParentCode = "";
	    DefaultMutableTreeNode ndSelectionNode = null;
	    TreePath path = ((DnDTree)formData.getControl("TreeArea")).getSelectionPath();
	    if(path != null)
	    {
		ndSelectionNode = (DefaultMutableTreeNode)path.getLastPathComponent();
		if(ndSelectionNode != ((DnDTree)formData.getControl("TreeArea")).getRoot())
		{
		    Vector vtSelectionNode = (Vector)ndSelectionNode.getUserObject();
		    strAreaId = StringUtil.nvl(vtSelectionNode.elementAt(6),"");
		    strOldParentCode = StringUtil.nvl(vtSelectionNode.elementAt(1),"");

		    if(ndSelectionNode.getChildCount() > 0)
		    {
			for(int iCheckChild = 0;iCheckChild < ndSelectionNode.getChildCount();iCheckChild++)
			{
			    DefaultMutableTreeNode ndCheckChild = (DefaultMutableTreeNode)ndSelectionNode.getChildAt(iCheckChild);
			    Vector vtCheckChild = (Vector)ndCheckChild.getUserObject();
			    if(vtCheckChild.elementAt(0).toString().equals(txtParentCode.getText()))
			    {
				MessageBox.showMessageDialog(this,"Không thay đổi được node con thành node cha",Global.APP_NAME,MessageBox.ERROR_MESSAGE);
				return false;
			    }
			}
		    }
		}
	    }
	    else
	    {
		return false;
	    }
	    DataTransmit request = new DataTransmit();
	    request.setString("AreaCode",txtAreaCode.getText().trim());
	    request.setString("ParentCode",txtParentCode.getText().trim());
	    request.setString("Name",txtName.getText().trim());
	    request.setString("FullName",txtFullName.getText().trim());
	    request.setString("Center",StringUtil.nvl(cboCenter.getSelectedValue(),""));
	    request.setString("Status",StringUtil.nvl(cboStatus.getSelectedValue(),""));
	    request.setString("mstrPrimaryKey",strAreaId);
	    DataTransmit response = AppClient.sendRequest("telsoft.app.bean.AreaBean","update",request);
	    //Update UI
	    Vector vtArea = new Vector();
	    vtArea.setSize(7);
	    vtArea.add(0,txtAreaCode.getText().trim());
	    vtArea.add(1,txtParentCode.getText().trim());
	    vtArea.add(2,txtName.getText().trim());
	    vtArea.add(3,txtFullName.getText().trim());
	    vtArea.add(4,StringUtil.nvl(cboCenter.getSelectedValue(),""));
	    vtArea.add(5,StringUtil.nvl(cboStatus.getSelectedValue(),""));
	    vtArea.add(6,strAreaId);
	    if(txtParentCode.getText().equals(strOldParentCode))
	    {
		ndSelectionNode.setUserObject(vtArea);
		((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).nodeChanged(ndSelectionNode);
	    }
	    else
	    {
		ndSelectionNode.setUserObject(vtArea);
		((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).nodeChanged(ndSelectionNode);
		searchNode(txtParentCode.getText(),((DnDTree)formData.getControl("TreeArea")).getRoot());
		if(ndResultSearch.getChildCount() == 0)
		{
		    ndResultSearch.setAllowsChildren(true);
		}
		((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).removeNodeFromParent(ndSelectionNode);
		((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).insertNodeInto(ndSelectionNode,ndResultSearch,ndResultSearch.getChildCount());
		((DnDTree)formData.getControl("TreeArea")).setSelectionPath(new TreePath(((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).getPathToRoot(ndSelectionNode)));
	    }
	}
	catch(Exception e)
	{
	    e.printStackTrace();
	    MessageBox.showMessageDialog(this,e,Global.APP_NAME,MessageBox.ERROR_MESSAGE);
	    txtAreaCode.requestFocus();
	    return false;
	}
	return true;
    }

    ////////////////////////////////////////////////////////
    public boolean remove()
    {
	try
	{
	    DefaultMutableTreeNode ndSelectionNode = null;
	    TreePath[] paths = ((DnDTree)formData.getControl("TreeArea")).getSelectionPaths();
	    if(paths.length > 0)
	    {
		if(!checkBeforeRemove(paths))
		{
		    throw new AppException("Không thể xóa khu vực có chứa các khu vực trực thuộc");
		}
		else
		{
		    for(int iIndex = 0;iIndex < paths.length;iIndex++)
		    {
			ndSelectionNode = (DefaultMutableTreeNode)paths[iIndex].getLastPathComponent();
			DefaultMutableTreeNode ndParent = (DefaultMutableTreeNode)ndSelectionNode.getParent();
			Vector vtSelectionNode = (Vector)ndSelectionNode.getUserObject();
			DataTransmit request = new DataTransmit();
			request.setString("mstrPrimaryKey",StringUtil.nvl(vtSelectionNode.elementAt(6),""));
			AppClient.sendRequest("telsoft.app.bean.AreaBean","delete",request);
			//Update UI
			((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).removeNodeFromParent(ndSelectionNode);
			((DnDTree)formData.getControl("TreeArea")).setSelectionPath(new TreePath(((DefaultTreeModel)((DnDTree)formData.getControl("TreeArea")).getModel()).getPathToRoot(ndParent)));
		    }
		}
	    }
	}
	catch(Exception e)
	{
	    e.printStackTrace();
	    MessageBox.showMessageDialog(this,e,Global.APP_NAME,MessageBox.ERROR_MESSAGE);
	    return false;
	}
	return true;
    }
//
//    ////////////////////////////////////////////////////////
    public boolean search()
    {
	Vector vtAreaData = new Vector();
	boolean bReturn = true;
	try
	{
	    DataTransmit request = new DataTransmit();;
	    DataTransmit response = AppClient.sendRequest("telsoft.app.bean.AreaBean","query",request);
	    vtAreaData = (Vector)response.getReturn();
	}
	catch(Exception e)
	{
	    e.printStackTrace();
	    MessageBox.showMessageDialog(this,e,Global.APP_NAME,MessageBox.ERROR_MESSAGE);
	    bReturn = false;
	}
	// Build tree
	Vector mvtRoot = new Vector();
	mvtRoot.setSize(6);
	mvtRoot.add(0,"");
	mvtRoot.add(1,"");
	mvtRoot.add(2,"");
	mvtRoot.add(3,getDictionary().getString("AllArea"));
	mvtRoot.add(4,"");
	mvtRoot.add(5,"");
	DefaultMutableTreeNode ndRoot = new DefaultMutableTreeNode(mvtRoot);
	ndRoot.setAllowsChildren(true);
	((DnDTree)formData.getControl("TreeArea")).setRoot(ndRoot);
	//Het buoc tao node goc
	buildTree(vtAreaData,ndRoot);

	if(((DnDTree)formData.getControl("TreeArea")).getRowCount() > 0)
	{
	    ((DnDTree)formData.getControl("TreeArea")).setSelectionRow(0);
	}
	return bReturn;
    }

    ////////////////////////////////////////////////////////
    private boolean checkBeforeRemove(TreePath[] pPathsCheck)//kiem tra trươc khi xoa
    {
	for(int iIndex = 0;iIndex < pPathsCheck.length;iIndex++)
	{
	    DefaultMutableTreeNode ndCheck = (DefaultMutableTreeNode)pPathsCheck[iIndex].getLastPathComponent();
	    if(ndCheck.isRoot() || ndCheck.getChildCount() > 0)//neu la nut goc hoac la nut cha
	    {
		return false;
	    }
	}
	return true;
    }

    ////////////////////////////////////////////////////////
    private void searchNode(String NodeID,DefaultMutableTreeNode ndNode)
    {
	//1. If ndNode have childnode then seek its
	if(ndNode.getChildCount() > 0)
	{
	    for(int i = 0;i < ndNode.getChildCount();i++)
	    {
		DefaultMutableTreeNode ndChild = (DefaultMutableTreeNode)ndNode.getChildAt(i);
		Vector vtTemp = (Vector)ndChild.getUserObject();
		//2. If current node have ID = NodeID then ndResultSearch is current node
		if(vtTemp.elementAt(0).toString().equals(NodeID))
		{
		    ndResultSearch = ndChild;
		}
		//3. Else recursive seek with current node
		else
		{
		    searchNode(NodeID,ndChild);
		}
	    }
	}
    }

    ////////////////////////////////////////////////////////
    private void buildTree(Vector vtTree,DefaultMutableTreeNode ndRoot)
    {
	//1. vtTree:Data for buiding tree, ndRoot:root of tree
	for(int i = 0;i < vtTree.size();i++)
	{
	    Vector vtTemp = (Vector)vtTree.elementAt(i);
	    Vector vtRoot = (Vector)ndRoot.getUserObject();
	    if(vtTemp.elementAt(1).equals(vtRoot.elementAt(0)))
	    {
		//////Add node
		DefaultMutableTreeNode ndChild = new DefaultMutableTreeNode(vtTemp);
		ndRoot.add(ndChild);
	    }
	}
	//2. Using condition for adding a node
	if(ndRoot.getChildCount() == 0)
	{
	    ndRoot.setAllowsChildren(false);
	    return;
	}
	//3. With node current adding, recursive buidTree
	for(int i = 0;i < ndRoot.getChildCount();i++)
	{
	    DefaultMutableTreeNode ndChild = (DefaultMutableTreeNode)ndRoot.getChildAt(i);
	    buildTree(vtTree,ndChild);
	}
    }

    ////////////////////////////////////////////////////////
    private DefaultMutableTreeNode createTreeNode(Vector vtRow)
    {
	DefaultMutableTreeNode ndChild = new DefaultMutableTreeNode(vtRow);
	return ndChild;
    }

    ////////////////////////////////////////////////////////
    private void fillTableArea()//day du lieu vao bang
    {
	Thread thr = new Thread()
	{
	    public void run()
	    {
		try
		{
		    TreePath path = ((DnDTree)formData.getControl("TreeArea")).getSelectionPath();
		    if(path != null)
		    {
			DefaultMutableTreeNode ndSelectionNode = (DefaultMutableTreeNode)path.getLastPathComponent();
			if(ndSelectionNode.isRoot())
			{
//                            DDTP request = new DDTP();
//                            DDTP response = AppClient.sendRequest("telsoft.app.bean.AreaBean","QueryGroup",request);
//                            Vector vtResult = (Vector)response.getReturn();
//                            tblAreaList.setData(vtResult);
			    tblAreaList.deleteAllRow();
			}
			else
			{
			    Vector vtSelectionNode = (Vector)ndSelectionNode.getUserObject();
			    DataTransmit request = new DataTransmit();
			    request.setString("mstrParentID",StringUtil.nvl(vtSelectionNode.elementAt(0),""));
			    DataTransmit response = AppClient.sendRequest("telsoft.app.bean.AreaBean","QueryChild",request);
			    Vector vtResult = (Vector)response.getReturn();
			    tblAreaList.setData(vtResult);
			}
		    }
		}
		catch(Exception e)
		{
		    e.printStackTrace();
		}
	    }
	};
	thr.start();
    }

    ////////////////////////////////////////////////////////
    private void fillDetailValue()
    {
	TreePath path = ((DnDTree)formData.getControl("TreeArea")).getSelectionPath();
	if(path != null)
	{
	    DefaultMutableTreeNode ndSelectedNode = (DefaultMutableTreeNode)path.getLastPathComponent();
	    if(ndSelectedNode != ((DnDTree)formData.getControl("TreeArea")).getRoot())
	    {
		Vector vtSelectionNode = (Vector)ndSelectedNode.getUserObject();
		txtAreaCode.setText(StringUtil.nvl(vtSelectionNode.elementAt(0),""));
		txtParentCode.setText(StringUtil.nvl(vtSelectionNode.elementAt(1),""));
		txtName.setText(StringUtil.nvl(vtSelectionNode.elementAt(2),""));
		txtFullName.setText(StringUtil.nvl(vtSelectionNode.elementAt(3),""));
		cboCenter.setSelectedValue(StringUtil.nvl(vtSelectionNode.elementAt(4),""));
		cboStatus.setSelectedValue(StringUtil.nvl(vtSelectionNode.elementAt(5),""));
	    }
	    else
	    {
		fillDefaultValue();
	    }
	}
    }

    ////////////////////////////////////////////////////////
    private void clearDetailValue()
    {
	try
	{
	    formData.clearFieldValueExclude(new String[]
					    {"tblAreaList"});
	}
	catch(Exception ex)
	{
	    ex.printStackTrace();
	    MessageBox.showMessageDialog(this,ex,Global.APP_NAME,MessageBox.ERROR_MESSAGE);
	}
    }

    ////////////////////////////////////////////////////////
    private void fillDefaultValue()
    {
	try
	{
	    formData.clearFieldValueExclude(new String[]
					    {"tblAreaList"});
	}
	catch(Exception ex)
	{
	    ex.printStackTrace();
	    MessageBox.showMessageDialog(this,ex,Global.APP_NAME,MessageBox.ERROR_MESSAGE);
	}
    }

    ////////////////////////////////////////////////////////
    public boolean validateInput(int iOldAction,int iNewAction)
    {
	if(iOldAction == ACTION_NONE && (iNewAction == ACTION_REMOVE || iNewAction == ACTION_MODIFY))
	{
	    TreePath path = ((DnDTree)formData.getControl("TreeArea")).getSelectionPath();
	    if(path != null)
	    {
		if(path.getLastPathComponent() == ((DnDTree)formData.getControl("TreeArea")).getRoot())
		{
		    return false;
		}
	    }
	}
	if((iOldAction == ACTION_ADD || iOldAction == ACTION_MODIFY)
	   && iNewAction == ACTION_SAVE)
	{
	    return validateInput();
	}
	return true;
    }

    ////////////////////////////////////////////////////////
    public void onChangeAction(int _int,int iNewAction)
    {
	if(iNewAction == ACTION_NONE)
	{
	    formData.setFieldEnabled(false);
	    tblAreaList.setEnabled(true);
	    tblAreaList.requestFocus();
	    fillDetailValue();
	}
	else if(iNewAction == ACTION_ADD || iNewAction == ACTION_MODIFY || iNewAction == ACTION_ADD_COPY)
	{
	    formData.setFieldEnabled(true);
	    tblAreaList.setEnabled(false);
	    txtAreaCode.requestFocus();
	    ((DnDTree)formData.getControl("TreeArea")).setEnabled(false);
	    if(iNewAction == ACTION_ADD)
	    {
		fillDefaultValue();
		txtParentCode.setEnabled(false);
		TreePath path = ((DnDTree)formData.getControl("TreeArea")).getSelectionPath();
		if(path != null)
		{
		    DefaultMutableTreeNode ndSelectionNode = (DefaultMutableTreeNode)path.getLastPathComponent();
		    Vector vtSelectionNode = (Vector)ndSelectionNode.getUserObject();
		    txtParentCode.setText(vtSelectionNode.elementAt(0).toString());
		}
	    }
	    else if(iNewAction == ACTION_ADD_COPY)
	    {
		txtParentCode.setEnabled(false);
	    }
	    else if(iNewAction == ACTION_MODIFY)
	    {
		txtAreaCode.setEnabled(false);
	    }
	}
	else if(iNewAction == ACTION_SAVE || iNewAction == ACTION_CANCEL)
	{
	    ((DnDTree)formData.getControl("TreeArea")).setEnabled(true);
	    int rowCount = tblAreaList.getRowCount();
	    if(rowCount > 0)
	    {
		fillDetailValue();
	    }
	    else
	    {
		clearDetailValue();
	    }
	}
    }

    ////////////////////////////////////////////////////////
    public String getPermission()
    {
	return telsoft.admin.util.AppClient.getPermission(telsoft.app.util.PermissionApp.FormArea);
    }
}
